<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>Title</title>
    <script type="text/javascript" src="js/jquery-1.12.4.js"></script>
    <script type="text/javascript" src="js/bootstrap.js"></script>
    <link rel="stylesheet" href="css/bootstrap.css">
    <script type="text/javascript" src="js/vue-2.6.12.js"></script>
    <script type="text/javascript" src="js/axios-0.21.0.js"></script>
</head>
<body>
<div id="app" class="container" style="margin-top:20px">
    <hr style="border:solid 2px red">
    <div class="row">
        <div class="col-md-offset-1 col-md-5">
            <h4>全球最大的珠宝销售网站</h4>
            <hr>
            <ul>
                <li><span>丰富多样</span>
                    <p class="text-muted">
                        涵盖钻石、黄金、铂金、珍珠、翡翠、彩色宝石等各类材质，款式新颖独特，既有日常佩戴的简约设计，也有为特殊场合量身定制的华丽首饰。</p>
                </li>
                <li><span>个性化定制</span>
                    <p class="text-muted">
                        提供专业的珠宝定制服务，让每一位客户都能够根据个人品味与情感寄托创作独一无二的珠宝作品。</p>
                </li>
                <li><span>专业认证与保障</span>
                    <p class="text-muted">
                        每一款珠宝均经过国家认可的专业机构严格检测，并出具详细的商品质量证书，确保每一份投资与收藏都物有所值。</p>
                </li>
            </ul>
        </div>
        <div class="col-md-4 col-md-offset-1">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">登录在线珠宝商城官网</h3>
                </div>
                <div class="panel-body" style="background:#F5F5F5">
                    <form class="form-horizontal">
                        <div class="form-group">
                            <label for="inputEmail3" class="col-sm-2 control-label">账户</label>
                            <div class="col-sm-10">
                                <input type="email" class="form-control" id="inputEmail3" placeholder="username"
                                       v-model="user.userName">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword3" class="col-sm-2 control-label">密码</label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" id="inputPassword3" placeholder="Password"
                                       v-model="user.password">
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="button" class="btn btn-default" @click="login">登录</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="panel-footer">
                    <h5 style="font-weight: 500">您还不是用户？</h5>
                    <h6 style="text-align:right;color:blue">
                        <a href="register.html">创建一个新用户</a>
                    </h6>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    new Vue({
        el: "#app",
        data: {
            user: {
                userName: "",
                password: ""
            }
        },
        methods: {
            login() {
                console.log(this.user);
                if (this.user.password === "") {
                    alert("请输入密码");
                } else {
                    axios.post("/user/login", this.user).then(resp => {
                        console.log(resp.data.message)
                        if (resp.data.message === "admin-success") {
                            alert("管理员登录成功")
                            location.href = "/back/content.html";
                        } else if (resp.data.message === "user-not-existed") {
                            alert("用户不存在,请先去注册");
                            location.href = "register.html";
                        } else if (resp.data.message === "success") {
                            alert("登录成功")
                            location.href = "/front/main.html";
                        } else {
                            alert("密码错误");
                        }
                    }).catch(error => console.log(error))
                }
            }
        }
    })
</script>
</html>